//
//  DWMaskViewController.m
//  OCAPPDemo
//
//  Created by OS on 2023/1/17.
//

#import "DWMaskViewController.h"

@interface DWMaskViewController ()

@end

@implementation DWMaskViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"mask";
    self.view.backgroundColor = [UIColor whiteColor];
    
    UIImageView *imageView = [[UIImageView alloc] init];
    imageView.image = [UIImage imageNamed:@"lyf"];
    imageView.frame = self.view.bounds;
    imageView.contentMode = UIViewContentModeScaleAspectFit;
    [self.view addSubview:imageView];
    
    CGRect viewRect = self.view.bounds;
    
    UIBezierPath *path = [UIBezierPath bezierPath];
//    [path moveToPoint:CGPointMake(viewRect.size.width / 2, 200)];
//    [path addLineToPoint:CGPointMake(20, viewRect.size.height / 2)];
//    [path addQuadCurveToPoint:CGPointMake(viewRect.size.width - 20, viewRect.size.height / 2) controlPoint:CGPointMake(viewRect.size.width / 2, viewRect.size.height / 2 + 400)];
//    [path closePath];
    
    [path addArcWithCenter:CGPointMake(viewRect.size.width / 2, viewRect.size.height / 2) radius:viewRect.size.width / 3 startAngle:0 endAngle:M_PI * 2 clockwise:YES];
    
    CAShapeLayer *maskLayer = [CAShapeLayer layer];
    maskLayer.path = path.CGPath;
    maskLayer.fillColor = [UIColor clearColor].CGColor;
    maskLayer.strokeColor = [UIColor redColor].CGColor;
    maskLayer.lineWidth = 30;
    imageView.layer.mask = maskLayer;
    
    
//    CABasicAnimation * animation = [CABasicAnimation animation];
//    animation.keyPath = @"strokeEnd";
//    animation.duration = 3;
//    animation.fromValue = @0;
//    [maskLayer addAnimation:animation forKey:nil];
    
    
}




@end
